//
//  UIBarButtonItem+ISBarButtonItem.m
//  iSocket
//
//  Created by lhj on 1/19/16.
//  Copyright © 2016 boer. All rights reserved.
//

#import "UIBarButtonItem+ISBarButtonItem.h"

@implementation UIBarButtonItem (ISBarButtonItem)

+ (instancetype)itemWithTarget:(id)target action:(SEL)action image:(NSString *)image highImage:(NSString *)highImage isLeft:(BOOL)isLeft
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 22, 22);
    CGFloat offset = isLeft ? -5 : 5;
    button.contentEdgeInsets = UIEdgeInsetsMake(0, offset, 0, - offset);
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    [button setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",image]] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",highImage]] forState:UIControlStateHighlighted];

    return [[self alloc] initWithCustomView:button];
}

@end
